package com.guigu.wenzhiyi.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.wenzhiyi.mapper.MentalityresultMapper;
import com.guigu.wenzhiyi.pojo.Mentalityresult;
import com.guigu.wenzhiyi.service.MentalityresultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MentalityresultServiceImpl implements MentalityresultService {

    @Autowired
    MentalityresultMapper mentalityresultMapper;


    @Override
    public PageInfo<Mentalityresult> page(Integer num, Integer size, String name) {
        PageHelper.startPage(num,size);
        List<Mentalityresult> list =mentalityresultMapper.page(name);
        PageInfo<Mentalityresult> p = new PageInfo<>(list);
        return p;
    }

    @Override
    public int add(Mentalityresult bodytype) {
        int insert = mentalityresultMapper.insert(bodytype);
        return bodytype.getId();
    }

    @Override
    public int update(Mentalityresult bodytype) {
        return mentalityresultMapper.updateByPrimaryKeySelective(bodytype);
    }

    @Override
    public int delete(Integer id) {
        return mentalityresultMapper.deleteByPrimaryKey(id);
    }
}
